import 'package:dark_notes/main.dart';
import 'package:dark_notes/pages/newnotepage.dart';
import 'package:dark_notes/pages/viewnotepage.dart';
import 'package:flutter/material.dart';
import 'package:dark_notes/models/notemodel.dart';

class NoteTile extends StatelessWidget {
  final Note note;
  NoteTile({this.note});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: () {
          Navigator.push(
              context,
              MaterialPageRoute(
                  builder: (context) => ViewNotePage(title: '详情', note: note)));
        },
        child: Card(
          child: Container(
              padding: EdgeInsets.all(8),
              child: Column(
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          this.note.title,
                          style: Theme.of(context).textTheme.headline5,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                      )
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          this.note.body,
                          style: Theme.of(context).textTheme.bodyText1,
                          maxLines: 5,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                    ],
                  ),
                ],
              )),
        ));
  }
}
